package com.sewisdom.ng.act.util.caoyt;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Random;

import com.sewisdom.mmorpg.fw.sys.arena.ArenaRank;
import com.sewisdom.mmorpg.fw.sys.arena.ArenaRankStore;
import com.sewisdom.ng.act.util.caoyt.log.OwnLog;

public class ArenaUtil {

	public static  ArenaRank getCharacterRank(int charaId) {
		ArenaRankStore arenaRankStore = ArenaRankStore.getInstance();
		List<ArenaRank> arenaRanks = arenaRankStore.getArenaRanks();
		for(ArenaRank rank : arenaRanks){
			if(rank.getActorId() == charaId){
				return rank;
			}
		}
		return null;
	}
	public static long timeStr2Long(String timeStr){
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date = null;
		try {
			date = format.parse(timeStr);
			Calendar cal = Calendar.getInstance();
			cal.setTime(date);
			return cal.getTimeInMillis();
		} catch (ParseException e) {
			OwnLog.logExcep(e);
		}
		return 0;
	}
	
	private final static Random random = new Random();
	
	public static Random getRandom(){
		return random;
	}
}
